package com.wqnmdb.im.controller;

import com.wqnmdb.im.exception.ParamsException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;

/**
 * @Package: com.wetran.app.web.controller
 * @ClassName: AbstractController
 * @Description: 说明小样儿
 * @Author: 王欣
 * @CreateDate: 2018-5-3 16:01
 * @Version: 1.0
 */
@Slf4j
public abstract class AbstractController {

    /**
     * 检查参数
     */
    protected void checkParams(BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            log.error("参数校验异常：{}.", bindingResult.getFieldErrors().get(0).getDefaultMessage());
            throw new ParamsException(bindingResult);
        }else {
            log.info("参数校验通过.");
        }
    }
}
